Skip to content

Add Ki recovery from eKi and fix OPC return type#14

Open
Takuto88 wants to merge 3 commits into
iotconnectivity:masterfrom
Takuto88:feature/recover-ki
Open

Add Ki recovery from eKi and fix OPC return type#14
Takuto88 wants to merge 3 commits into
iotconnectivity:masterfrom
Takuto88:feature/recover-ki

Conversation

@Takuto88

Copy link
Copy Markdown

Two changes:

  1. Fix: binascii.hexlify() returns bytes in Python 3, causing OPC values to be bytes instead of strings. This made dict output inconsistent.
  2. Feature: Added aes_128_cbc_decrypt() and recover_ki() to reverse eKi encryption, plus a -e/--eki CLI flag to recover Ki (with OPC and eKi) from an encrypted triplet given the OP and Transport Key.

Usage:

kiopcgen -o <OP> -t <TransportKey> -e <eKi>

At C3GSM, we regularly order eSIMs and have this problem. We're using this code to generate eKi from Ki and also use it for the OPc values. It felt fair to upstream this back to you <3

Takuto88 added 3 commits June 22, 2026 00:38
binascii.hexlify returns bytes in Python 3, causing OPC values to be
bytes instead of strings. This made dict output inconsistent (mixed
str/bytes).
Adds aes_128_cbc_decrypt and recover_ki to reverse the eKi encryption,
and a -e/--eki CLI flag to recover Ki (with OPC and eKi) from an
encrypted triplet given the OP and Transport Key.
@Takuto88 Takuto88 force-pushed the feature/recover-ki branch from bfa89f0 to 07a04ed Compare June 21, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant